import Vue from 'vue'
import VueRouter from 'vue-router'
// 导入路由页面组件
// @ 是webpack内置路由变量，代表src绝对路径
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Search from '@/views/Search'
import Play from '@/views/Play'

// 注册路由为中间件
Vue.use(VueRouter)

// 配置路由信息
const routes = [
    {path: '/', redirect: '/layout' },
    {path: '/layout', redirect: '/layout/home', component: Layout, children:[
        {path: 'home', component: Home, meta: {title: '首页'} },
        {path: 'search', component: Search, meta: {title: '搜索'}},
    ]},
    {path: '/play', component: Play}
]

// 实例化路由对象
const router = new VueRouter({
    routes: routes
})

// 导出路由对象
export default router